<template>
  <div class="lie">
    <div class="biao">
      <p>
        &nbsp;&nbsp;&nbsp;优选童书<span
          >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;| 让孩子爱上阅读
          塑造好性格</span
        ><span>更多></span>
      </p>
    </div>
    <ul>
      <li v-for="item in state.shoplist" :key="item._id">
        <img :src="item.url" alt="" />
        <p>{{ item.msg }}</p>
        <em>{{ item.title }}</em>
        <p class="pp">
          <span>￥{{ item.price }}</span>
          <span
            ><img src="https://z3.ax1x.com/2021/07/19/WYVctK.png" alt=""
          /></span>
        </p>
      </li>
    </ul>
    <div class="biao">
      <p>
        &nbsp;&nbsp;&nbsp;优选童书<span
          >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;| 让孩子爱上阅读
          塑造好性格</span
        ><span>更多></span>
      </p>
    </div>
    <ul>
      <li v-for="item in state.shoplist" :key="item._id">
        <img :src="item.url" alt="" />
        <p>{{ item.msg }}</p>
        <em>{{ item.title }}</em>
        <p class="pp">
          <span>￥{{ item.price }}</span>
          <span
            ><img src="https://z3.ax1x.com/2021/07/19/WYVctK.png" alt=""
          /></span>
        </p>
      </li>
    </ul>
    <van-list
      v-model:loading="state.loading"
      :finished="state.finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <van-cell v-for="item in state.list" :key="item" :title="item" />
    </van-list>
  </div>
</template>

<script>
import { reactive, computed, onMounted } from "vue";
import { useStore } from "vuex";
export default {
  setup() {
    const store = useStore();
    const state = reactive({
      shoplist: computed(() => store.state.shopList),
      loading: false,
      finished: false,
    });
    const onLoad = () => {
      setTimeout(() => {
        for (let i = 0; i < 0; i++) {
          state.shoplist.push(state.shoplist.length + 1);
        }

        state.loading = false;

        if (state.shoplist.length >= 1) {
          state.finished = true;
        }
      }, 2000);
    };
    onMounted(() => {
      getShopList();
    });

    const getShopList = () => {
      store.dispatch("changeShopAsync");
    };
    return {
      state,
      onLoad,
    };
  },
};
</script>

<style lang="less">
.lie {
  background: #f7f7f7;
  height: 100%;

  .biao {
    height: 50px;
    line-height: 50px;
    p {
      padding: 0;
      margin: 0;
      height: 17px;
      font-size: 17px;
      font-family: PingFangSC;
      font-weight: 600;
      color: #272727;
      position: relative;
    }
    span:nth-child(1) {
      font-size: 11.5px;
      font-family: PingFangSC;
      font-weight: 600;
      color: #747474 !important;
    }
    span:nth-child(2) {
      font-size: 13px;
      font-family: PingFangSC;
      font-weight: 600;
      color: #747474;
      position: absolute;
      right: 12px;
      top: 0px;
    }
  }

  ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    margin-bottom: 35px;
    li {
      border: 1px solid lightgray;
      flex-direction: column;
      text-align: center;
      justify-content: space-around;
      width: 170px;
      height: 250.5px;
      background: #fefefe;
      border-radius: 5px;
      margin: 15px 0;
      padding: 5px;
      img {
        width: 128px;
        height: 154px;
      }
      p {
        line-height: 15px;
        margin: 8px 0;
        height: 15px;
        font-size: 12.5px;
        font-family: PingFangSC;
        font-weight: 900;
        color: #2f2f2f;
        word-break: break-all;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      em {
        display: block;
        line-height: 20px;
        font-style: inherit;
        font-family: Adobe Heiti Std;
        font-weight: normal;
        color: #9b9b9b;
        word-break: break-all;
        font-size: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .pp {
        display: flex;
        justify-content: space-between;
        height: 30px;
        align-items: center;

        span {
          font-size: 17px;
          font-family: PingFangSC;
          font-weight: 400;
          color: #ec6d2a;
          line-height: 17px;
          img {
            display: block;
            width: 18px;
            height: 18px;
          }
        }
      }
    }
  }
  .van-list__loading {
    height: 100px;
  }
  .van-list__finished-text {
    height: 100px;
  }
}
</style>
